<template>
	<view class="content">
		<view class="title-content-item">
			<view class="title-content-item-left">提现方式</view>
			<view class="title-content-item-right">
				<image style="width: 16px;height: 16px;margin-right: 5px;" :src="wxImg" mode=""></image>
				微信
				<image style="width: 16px;height: 16px;margin-left: 5px;" :src="rightjiantou" mode=""></image>
			</view>
		</view>
		<view class="content-item">
			<view class="content-item-title">提现金额</view>
			<view class="content-item-bai">
				<view class="content-item-moneyIcon">￥</view>
				<input type="number" class="content-item-input" v-model="txMoney" focus>
				<view class="content-item-tip" @click="allTx">全部提现</view>
			</view>
			<view class="content-item-text">可提现金额:{{userAllMoney}}</view>
			<view class="content-item-btn" @click="gototx">提现</view>
		</view>
		<view class="content-item">
			<view class="content-item-title">提现流程</view>
			<view class="content-item-liucheng">
				<view class="content-item-liucheng-li">
					<image class="liucheng-icon" :src="liucheng01" mode=""></image>
					<view class="liucheng-text">余额提现</view>
				</view>
				<image class="liucheng-jiantou" :src="liuchengjiantou" mode=""></image>
				<view class="content-item-liucheng-li">
					<image class="liucheng-icon" :src="liucheng02" mode=""></image>
					<view class="liucheng-text">核验(3天内)</view>
				</view>
				<image class="liucheng-jiantou" :src="liuchengjiantou" mode=""></image>
				<view class="content-item-liucheng-li">
					<image class="liucheng-icon" :src="liucheng03" mode=""></image>
					<view class="liucheng-text">金额到账</view>
				</view>
			</view>
		</view>
		<view class="wenxin-box">
			<view class="wenxin-box-title">温馨提示:</view>
			<view class="wenxin-box-item">1. 这是一条很认真的提示规</view>
			<view class="wenxin-box-item">2. 这是一条很认真的提示规</view>
		</view>
		<view class="kefu-btn-box">
			<view class="kefu-btn">
				<image style="width: 17px;height: 17px;margin-right: 10px;" :src="kefuImg" mode=""></image>
				如有疑问，请咨询客服
			</view>
		</view>
		
	</view>
</template>

<script>
	import http from '../../api/api-index.js'
	import baseUrl from '../../utils/config.js'
	
	export default{
		data(){
			return{
				title:'回收人员中心',
				wxImg:baseUrl+'/uploads/static/image/recovery_ recycler_my_money_icon_withdrawal@2x.png',
				rightjiantou:baseUrl+'/uploads/static/image/right-jiantou.png',
				liucheng01:baseUrl+'/uploads/static/image/recovery_ recycler_my_money_withdrawal_process_icon_01@2x.png',
				liucheng02:baseUrl+'/uploads/static/image/recovery_ recycler_my_money_withdrawal_process_icon_02@2x.png',
				liucheng03:baseUrl+'/uploads/static/image/recovery_ recycler_my_money_withdrawal_process_icon_03@2x.png',
				liuchengjiantou:baseUrl+'/uploads/static/image/recovery_ recycler_my_money_withdrawal_process_line_img@2x.png',
				kefuImg:baseUrl+'/uploads/static/image/recovery_ recycler_my_money_withdrawal_icon_service@2x.png',
				txMoney:'',
				userAllMoney:0,
				type:0,//0用户 1回收人员
			}
		},
		onLoad(options) {
			this.type = options.type
			if(options.type == 0){
				//用户
				this.userAllMoney = Number(JSON.parse(uni.getStorageSync('userInfo')).info.money)
			}else{
				//回收人员
				this.userAllMoney = Number(JSON.parse(uni.getStorageSync('recyclerInfo')).money)
			}
		},
		methods:{
			allTx(){
				this.txMoney = this.userAllMoney
			},
			gototx(){
				const access_token = uni.getStorageSync('X-Auth-Token')
				if(this.type == 0){
					http.getUsersWithdrawalHandle({
						amount:this.txMoney,
						type:1
					},{
						"X-Auth-Token":access_token,
						'Content-Type': 'application/x-www-form-urlencoded'
					}).then((res)=>{
						if(res.data.code == 1){
							uni.showToast({
								title:res.data.msg,
								icon:'none'
							})
							setTimeout(function(){
								uni.navigateTo({
									url:'/pages/my/wallet'
								})
							},1500)
						}else{
							uni.showToast({
								title:res.data.msg,
								icon:'none'
							})
						}
					})
				}else{
					http.getRecyclersWithdrawalHandle({
						amount:this.txMoney,
						type:1
					},{
						"X-Auth-Token":access_token,
						'Content-Type': 'application/x-www-form-urlencoded'
					}).then((res)=>{
						console.log(res)
						if(res.data.code == 1){
							uni.showToast({
								title:res.data.msg,
								icon:'none'
							})
							setTimeout(function(){
								uni.navigateTo({
									url:'/pages/recoveryCenter/wallet'
								})
							},1500)
						}else{
							uni.showToast({
								title:res.data.msg,
								icon:'none'
							})
						}
					})
				}
				
			}
		}
	}
</script>

<style>
	.content{
		width: 100%;
		min-height: 100vh;
		overflow: hidden;
		background: #F8F9FD;
		font-family: 'PingFang Bold';
	}
	.title-content-item{width: calc(100% - 24px);margin: 0 auto;margin-top: 12px;border-radius: 10px;background: #fff;height: 50px;
	display: flex;flex-direction: row;align-items: center;justify-content: space-between;box-sizing: border-box;padding: 0 25px;}
	.title-content-item-left{font-size: 16px;color: #333;}
	.title-content-item-right{display: flex;flex-direction: row;align-items: center;font-size: 14px;}
	.content-item{width: calc(100% - 24px);margin: 0 auto;margin-top: 12px;border-radius: 10px;background: #fff;box-sizing: border-box;padding: 26px 25px;}
	.content-item-title{font-size: 16px;color: #333;}
	.content-item-bai{width: 100%;display: flex;flex-direction: row;align-items: center;margin-top: 30px;border-bottom:1px solid #f6f6f6;height: 60px;}
	.content-item-bai .content-item-moneyIcon{font-size: 36px;color: #333;}
	.content-item-bai .content-item-input{width: calc(100% - 100px);font-size: 40px;height: 40px;font-weight: bold;}
	.content-item-tip{font-size: 14px;color: #00CB8B;width: 60px;}
	.content-item-text{font-size: 13px;color: #999;margin-top: 8px;}
	.content-item-btn{width: 100%;margin-top: 25px;height: 48px;font-size: 17px;color:#fff;text-align: center;line-height: 48px;border-radius: 5px;background: #00CB8B;}
	.liucheng-icon{width: 36px;height: 36px;}
	.content-item-liucheng{width: 100%;display: flex;flex-direction: row;align-items: center;margin-top: 30px;}
	.content-item-liucheng-li{flex: 2;display: flex;flex-direction: column;align-items: center;justify-content: center;}
	.liucheng-text{margin-top: 8px;font-size: 14px;}
	.liucheng-jiantou{width: 43px;height: 10px;margin-bottom: 20px;}
	.wenxin-box{width: 100%;box-sizing: border-box;padding: 20px 30px;}
	.wenxin-box-title{font-size: 14px;color: #333;margin-bottom: 8px;}
	.wenxin-box-item{font-size: 12px;color: #999;margin-bottom: 5px;}
	.kefu-btn-box{width: 100%;position: fixed;bottom: 0;left: 0;height: calc(70px + env(safe-area-inset-bottom) /2);background: #fff;box-sizing: border-box;padding: 5px 22px;}
	.kefu-btn{width: 100%;height: 45px;border: 1px solid #00CB8B;border-radius: 5px;display: flex;flex-direction: row;align-items: center;justify-content: center;color: #00CB8B;}
</style>